package com.vodone.v1pin.video.delegate
{
	import com.vodone.v1pin.video.view.vo.VideoVO;
	
	import mx.collections.ArrayCollection;

	public class VideoUtil
	{
		public static function getVideoListFromObj(obj:Object):ArrayCollection
		{
			var list:ArrayCollection = new ArrayCollection();
			if(obj && obj is Array)
			{
				var arr:Array = obj as Array;
				if(arr && arr.length > 0)
				{
					for(var i:int = 0; i< arr.length ; i++)
					{
						list.addItem(getVideoItem(arr[i]));
					}
				}
			}
			return list;
		}
		public static function getVideoItem(obj:Object):VideoVO
		{
			var item:VideoVO = new VideoVO();
			if(obj)
			{
				if(obj.hasOwnProperty("Autoid"))
				{
					item.autoid = obj["Autoid"];
				}
				if(obj.hasOwnProperty("VideoUrl"))
				{
					item.VideoUrl = obj["VideoUrl"];
				}
				if(obj.hasOwnProperty("VideoName"))
				{
					item.VideoName = obj["VideoName"];
				}
				if(obj.hasOwnProperty("VideoImg"))
				{
					item.VideoImg = obj["VideoImg"];
				}
				if(obj.hasOwnProperty("Type"))
				{
					item.Type = obj["Type"];
					item.isOnLine = item.Type == "1";
				}
				if(obj.hasOwnProperty("ProductCode"))
				{
					item.ProductCode = obj["ProductCode"];
				}
			}
			return item;
		}
	}
}